<template>
  <el-row class="tac">
    <div class="header-wrap">
      <el-col class="header">
        <header>
          <i class="iconfont" @click="toggleClick" :style="{'margin-left':spanLeft+10+'px'}">&#xe699;</i>
          <div class="user-login">
            <el-col class="userbox">
              <span class="user-name"><a href="http://platform.vacomall.cn/" target="_blank">{{sysUserName}}</a></span>
              <span class="logout" @click="logout">退出登录</span>
            </el-col>
          </div>
        </header>
      </el-col>
    </div>
    <Sidebar :spanLeft="spanLeft"></Sidebar>
    <el-col class="content-wrap" :style="{'padding-left': spanLeft+'px'}">
      <div class="content">
        <router-view></router-view>
      </div>
    </el-col>
  </el-row>
</template>
<script>
  import Sidebar from './components/Sidebar'
  import axios from 'axios'
  import api from './store/api'
  export default {
    data () {
      return {
        spanLeft: 252,
        sysUserName: ''
      }
    },
    components: {
      Sidebar
    },
    methods: {
      toggleClick () {
        if (this.spanLeft === 252) {
          this.spanLeft = 60
        } else {
          this.spanLeft = 252
        }
      },
      logout: function () {
        this.$confirm('确认退出吗？', '提示', {
        }).then(() => {
          sessionStorage.removeItem('user')
          window.open('http://id.vacomall.cn/logout.html')
        }).catch(() => {
        })
      }
    },
    mounted () {
      axios.get(api.paltformUser)
        .then(response => {
          var result = response.data
          if (result.success) {
            const userName = result.data.userName
            this.sysUserName = userName
          } else {
            this.$message.error({
              title: '错误',
              message: result.message
            })
          }
        })
    }
  }
</script>
<style lang="scss" rel="stylesheet/scss">
  @font-face {
    font-family: 'iconfont';  /* project id 172093 */
    src: url('//at.alicdn.com/t/font_3x2ibco7v9muz0k9.eot');
    src: url('//at.alicdn.com/t/font_3x2ibco7v9muz0k9.eot?#iefix') format('embedded-opentype'),
    url('//at.alicdn.com/t/font_3x2ibco7v9muz0k9.woff') format('woff'),
    url('//at.alicdn.com/t/font_3x2ibco7v9muz0k9.ttf') format('truetype'),
    url('//at.alicdn.com/t/font_3x2ibco7v9muz0k9.svg#iconfont') format('svg');
  }

  .iconfont {
    font-family: "iconfont" !important;
    font-size: 16px;
    font-style: normal;
    -webkit-font-smoothing: antialiased;
    -webkit-text-stroke-width: 0.2px;
    -moz-osx-font-smoothing: grayscale;
  }

  body {
    overflow: hidden;
    min-width: 1190px;
    background: #f5f5f5;
    position: initial !important;
  }
  .user-login{
    float: right;
    height: 100%;
  }
  .header-right {
    float: right;
  }

  .content {
    min-width: 550px;
    margin: 10px;
    background: white;
    overflow: auto;
    border-radius: 2px;
    height: 100%;
    > * {
      margin: 10px 10px;
    }
    .buttons {
      padding: 0 10px 10px;
    }
    .page-wrap {
      padding: 10px;
      float: right;
    }
  }

  .content-wrap {
    position: absolute;
    height: 100%;
    padding-top: 60px;
    -webkit-transition: padding-left 0.3s;
    -moz-transition: padding-left 0.3s;
    -ms-transition: padding-left 0.3s;
    -o-transition: padding-left 0.3s;
    transition: padding-left 0.3s;
    -moz-transition: padding-left .3s;
    -webkit-transition: padding-left .3s;
    transition: padding-left .3s;
  }

  .header-img {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: 1px solid white;
    margin-top: 10px;
    margin-right: 10px;
    background: #324157;
    line-height: 35px;
    text-align: center;
    color: white;
  }

  header {
    height: 60px;
    background: white;
    line-height: 60px;
  }

  .tac {
    position: absolute !important;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
  }

  .el-breadcrumb {
    padding: 18px 0 9px 10px;
    margin-left: 16.7%;
  }

  .header-wrap {
    position: absolute;
    width: 100%;
    z-index: 2;
  }

  .header {
    float: right !important;
    -webkit-transition: width 0.3s;
    -moz-transition: width 0.3s;
    -ms-transition: width 0.3s;
    -o-transition: width 0.3s;
    transition: width 0.3s;
    -moz-transition: width .3s;
    -webkit-transition: width .3s;
    transition: width .3s;
  }

  header i {
    width: 100px;
    height: 100px;
    margin-left: 10px;
    font-size: 28px !important;
    color: #324157;
    cursor: pointer;
    -webkit-transition: margin-left 0.3s;
    -moz-transition: margin-left 0.3s;
    -ms-transition: margin-left 0.3s;
    -o-transition: margin-left 0.3s;
    transition: margin-left 0.3s;
    -moz-transition: margin-left .3s;
    -webkit-transition: margin-left .3s;
    transition: margin-left .3s;
  }
  .userbox{
    text-align: right;
    padding-right: 35px;
    float: right;
    line-height: 60px;
    font-size: 14px;
  }
  .user-name{
    color: #666666;
    margin-right: 10px;
  }
  .user-name a{
    text-decoration: none;
  }
  .logout{
    cursor: pointer;
  }
</style>

